﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<IList<UncleBobWebService.Models.JobModel>>" %>

<!DOCTYPE html>

<html>
    <head runat="server">
        <meta name="viewport" content="width=device-width" />

        <title>JobsListView</title>
        <link href="/Theme/UncleBobTheme.css" rel="Stylesheet" />  
        <script lang="cs" runat=server>
            protected void Page_Load(Object obj, EventArgs e)
            {
                HtmlTable mTable = (HtmlTable)this.form1.FindControl("tbJobList");
                string address = "/StaffingExpertMenu/CreateNewJob/";
                
                foreach (UncleBobWebService.Models.JobModel job in Model)
                {                    
                    HtmlTableRow row = new HtmlTableRow();
                    HtmlTableCell cell_1 = new HtmlTableCell();
                    HtmlTableCell cell_2 = new HtmlTableCell();
                    HtmlTableCell cell_3 = new HtmlTableCell();
                    HtmlTableCell cell_4 = new HtmlTableCell();
                    HyperLink link = new HyperLink()
                    {
                        Text = "Edit",
                        NavigateUrl = address + job.ID
                        
                    };
                    
                    
                    cell_1.Controls.Add(new Label() { Text = job.ID, Width = 80 });
                    cell_2.Controls.Add(new Label() { Text = job.Title, Width = 170 });
                    cell_3.Controls.Add(new Label() { Text = job.Location, Width = 250 });
                    cell_4.Controls.Add(link);
                    
                    row.Cells.Add(cell_1);
                    row.Cells.Add(cell_2);
                    row.Cells.Add(cell_3);
                    row.Cells.Add(cell_4);

                    mTable.Rows.Add(row);
                }
            }
        </script>      
    </head>

    <body class="body">
        <form id=form1 runat=server action="/StaffingExpertMenu/JobListFormAction">
            <!-- Headers -->
            <h2>Available Jobs</h2>

            <!-- Data List View -->
            <div class=box>
                <table class=content id=tbJobList runat=server>
                    <tr>
                        <td style="width: 80px">Job ID</td>
                        <td style="width: 170px">Job Title</td>
                        <td style="width: 250px">Job Location</td>
                    </tr>
                </table>
            </div>

            <!-- Buttons -->
            <div style="margin-top: 30px" >
                <input type=submit class=button name=back value=Back />
            </div>
        </form>
    </body>
</html>
